/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.quangtin3.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Quang
 */
@Entity
@Table(name = "collected_value")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CollectedValue.findAll", query = "SELECT c FROM CollectedValue c"),
    @NamedQuery(name = "CollectedValue.findByUser", query = "SELECT c FROM CollectedValue c WHERE c.collectedValuePK.user = :user"),
    @NamedQuery(name = "CollectedValue.findByCollectionColumn", query = "SELECT c FROM CollectedValue c WHERE c.collectedValuePK.collectionColumn = :collectionColumn"),
    @NamedQuery(name = "CollectedValue.findByCollectionColumnAndUser", query = "SELECT c FROM CollectedValue c WHERE c.collectedValuePK.collectionColumn = :collectionColumn and c.collectedValuePK.user = :user"),
    @NamedQuery(name = "CollectedValue.findByCollectedDate", query = "SELECT c FROM CollectedValue c WHERE c.collectedDate = :collectedDate"),
    @NamedQuery(name = "CollectedValue.findByValue", query = "SELECT c FROM CollectedValue c WHERE c.value = :value")})
public class CollectedValue implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CollectedValuePK collectedValuePK;
    @Column(name = "COLLECTED_DATE")
    @Temporal(TemporalType.DATE)
    private Date collectedDate;
    @Size(max = 256)
    @Column(name = "VALUE")
    private String value;
    @JoinColumn(name = "COLLECTION_COLUMN", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private CollectionColumn collectionColumn1;
    @JoinColumn(name = "USER", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private User user1;

    public CollectedValue() {
    }

    public CollectedValue(CollectedValuePK collectedValuePK) {
        this.collectedValuePK = collectedValuePK;
    }

    public CollectedValue(int user, int collectionColumn) {
        this.collectedValuePK = new CollectedValuePK(user, collectionColumn);
    }

    public CollectedValuePK getCollectedValuePK() {
        return collectedValuePK;
    }

    public void setCollectedValuePK(CollectedValuePK collectedValuePK) {
        this.collectedValuePK = collectedValuePK;
    }

    public Date getCollectedDate() {
        return collectedDate;
    }

    public void setCollectedDate(Date collectedDate) {
        this.collectedDate = collectedDate;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public CollectionColumn getCollectionColumn1() {
        return collectionColumn1;
    }

    public void setCollectionColumn1(CollectionColumn collectionColumn1) {
        this.collectionColumn1 = collectionColumn1;
    }

    public User getUser1() {
        return user1;
    }

    public void setUser1(User user1) {
        this.user1 = user1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (collectedValuePK != null ? collectedValuePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CollectedValue)) {
            return false;
        }
        CollectedValue other = (CollectedValue) object;
        if ((this.collectedValuePK == null && other.collectedValuePK != null) || (this.collectedValuePK != null && !this.collectedValuePK.equals(other.collectedValuePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.quangtin3.entity.CollectedValue[ collectedValuePK=" + collectedValuePK + " ]";
    }
    
}
